<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:f="http://java.sun.com/jsf/core">

     <ui:composition template="./WEB-INF/Templates/templateProjeto.xhtml">
        <ui:define name="titulo">Consulta de Situação de Lote/Remessa</ui:define>
        <ui:define name="javascript">
            function controlaRadio(){
                var campo1 = document.getElementById("form:situacao");
                var campoDtInicio = document.getElementById("form:dtInicio");
                var campoDtFim = document.getElementById("form:dtFim");

                if(document.getElementById("form:radio0").checked){
                    campo1.disabled=false;
                    campoDtInicio.disabled=true;
                    campoDtFim.disabled=true;
                 }
                 if(document.getElementById("form:radio1").checked){
                    campo1.disabled=true;
                    campoDtInicio.disabled=false;
                    campoDtFim.disabled=false;
                 }
            }

            function disableAll(){
                var campo1 = document.getElementById("form:situacao");
                var campoDtInicio = document.getElementById("form:dtInicio");
                var campoDtFim = document.getElementById("form:dtFim");
                
                if(document.getElementById("form:check").checked){
                    document.getElementById("form:painel").style.visibility = "hidden";
                    document.getElementById("form:botao_em_baixo").style.visibility = "hidden";
                    document.getElementById("form:botao_em_cima").style.visibility = "visible";
                    campo1.disabled=true;
                    campoDtInicio.disabled=true;
                    campoDtFim.disabled=true;

                }
                else{
                    document.getElementById("form:painel").style.visibility = "visible";
                    document.getElementById("form:botao_em_baixo").style.visibility = "visible";
                    document.getElementById("form:botao_em_cima").style.visibility = "hidden";
                    controlaRadio();
                }

            }
        </ui:define>
        <ui:define name="tituloH1">Consulta Situação de lote/remessa</ui:define>
        <ui:define name="pagLinda">
            <h1>Selecione os filtros para sua pesquisa</h1>
            <h:messages layout="list" style="color: darkred"/>
            <h:form id="form">
                <br/>
                <h:selectBooleanCheckbox id="check" onchange="disableAll()"/>
                <h:outputText value="Não aplicar filtros - Pesquisar tudo"/>
                <br/>
                <h:commandButton value="Pesquisar" id="botao_em_cima" style="visibility: hidden"/>
                
                <h:panelGrid columns="1" id="painel">
                    <h:panelGroup >
                        <t:selectOneRadio id="filtro" layout="spread" value="#{managedLoteRemessa.numRadioPesquisa}" onchange="controlaRadio()">
                                <f:selectItem itemLabel="Por situação de processamento de lote/remessa" itemValue="sit" />
                                <f:selectItem itemLabel="Por data de processamento" itemValue="pdt"/>
                        </t:selectOneRadio>

                        
                    <t:radio for="filtro" index="0" id="radio0" />
                    </h:panelGroup>
                    <h:panelGroup>
                 <!---->                      <!--Há 22 espaços invisiveis (alt+255) entre estes comentarios-->
                    <h:outputLabel value="Situação do lote/remessa"/>
                    <h:selectOneMenu id="situacao" value="#{managedLoteRemessa.loteRemessa.status}">
                         <f:selectItem itemLabel="Em Aberto" itemValue="0" />
                         <f:selectItem itemLabel="Em Análise" itemValue="1" />
                         <f:selectItem itemLabel="Aguardando envio para contratação" itemValue="2" />
                         <f:selectItem itemLabel="Em Contratação" itemValue="2" />
                         <f:selectItem itemLabel="Fechado" itemValue="2" />
                    </h:selectOneMenu>
                    </h:panelGroup>


                    <t:radio for="filtro" index="1" id="radio1"/>
                    <h:panelGroup>
                        <!---->                      <!--Há 22 espaços invisiveis (alt+255) entre estes comentarios-->
                        <h:outputLabel value="De"/>
                        <h:inputText id="dtInicio" value="#{managedLoteRemessa.dtInicio}" disabled="true">
                            <f:validateRequired/>
                        </h:inputText>
                        
                        <h:outputLabel value="ate"/>
                        <h:inputText id="dtFim" value="#{managedLoteRemessa.dtFim}" disabled="true">
                            <f:validateRequired/>
                        </h:inputText>
                    </h:panelGroup>
                </h:panelGrid>
                FAZER VALIDATOR DATA (DE NOVO)
                <h:commandButton value="pesquisar" id="botao_em_baixo" action="#{managedInscricao.procurar}"/>
                <script>
                    controlaRadio();
                    disableAll();
                </script>
            </h:form>
        </ui:define>
     </ui:composition>
    
</html>
